<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-9">
<title>Edit staff details</title>
<SCRIPT TYPE="text/javascript" src= "../../commonutils/util/util.js"> </SCRIPT>
</head>
<style type="text/css">
th {text-align: right}
</style>
<body>
<?php include '../../top.html' ?>
<?php include '../../authorization_check.php'; ?>
<?php include '../../checkStudentOnly.php'; ?>

<?php
  session_start();
 
  $programCode = $_SESSION['programCode'];
  $semesterID = $_SESSION['semesterID'];
  
  
?>


<?php
require_once '../../commonutils/db/DBConnectionManager.php';

$studentID = $_SESSION['uname'];

if (isset($_POST['btnSubmit']))
{
	
	$firstName = $_POST['txtFirstName'];
	$lastName= $_POST['txtLastName'];
	$citizenship = $_POST['txtTC_Kimlik'];
	
	$birthDate1 = $_POST['txtBirthDate1'];
	$birthDate2 = $_POST['txtBirthDate2'];
	$birthDate3 = $_POST['txtBirthDate3'];
	
	$birthDate = $birthDate3."-".$birthDate2."-".$birthDate1;
	$birthPlace = $_POST['txtBirthPlace'];
	
	$address = $_POST['txtAddress'];
	$homeTel = $_POST['txtHomeTel'];
	$officeTel = $_POST['txtOfficeTel'];
	$mobileTel = $_POST['txtMobileTel'];
	$academic = $_POST['txtAcademic'];
	
	$sqlquery = "update student set firstName = '".$firstName."' ".
						", lastName = '".$lastName."' ".
						", birthDate = '".$birthDate."' ".
						", birthPlace ='".$birthPlace."' ".
						", TC_Kimlik = '".$citizenship."' ".
						", address = '".$address."' ".
						", homeTel = '".$homeTel."' ".
						", officeTel = '".$officeTel."' ".
						", mobileTel = '".$mobileTel."' ".
						", academic = '".$academic."' ".
						" where studentID = ".$studentID;

							
	$result = DBConnectionManager::query($sqlquery);		
		

	//echo $sqlquery."<BR>"; 
	$result = DBConnectionManager::query($sqlquery);
	//$row = mysql_fetch_assoc($result);
	
}

 $sqlquery = " select firstname, lastname, birthDate, birthPlace, TC_Kimlik, address, homeTel, officeTel, mobileTel, academic from student where studentID = ".$studentID;
 //echo $sqlquery."<br>";
 $result = DBConnectionManager::query($sqlquery);
 $row = mysql_fetch_assoc($result);
 $firstName = $row['firstname'];
 $lastName = $row['lastname'];
 $birthDate = $row['birthDate'];
 $birthDate3 = substr($birthDate, 0, 4);
 $birthDate2 = substr($birthDate, 5, 2);
 $birthDate1 = substr($birthDate, 8, 2);
 $birthPlace = $row['birthPlace'];
 $citizenship = $row['TC_Kimlik'];
 $address = $row['address'];
 $homeTel = $row['homeTel'];
 $officeTel = $row['officeTel'];
 $mobileTel = $row['mobileTel'];
 $academic = $row['academic'];

?>
<center>
<form method="POST" action="UpdateStudentDetails.php">
<table border="1" width="56%" id="table1">
	<tr><td colspan="2" height="20"><center><h1>Update Student Details</h1></center></td></tr>
	<tr>
		<td width="112">Student ID</td>
		<td width="162"><?php echo($studentID) ?></td>
	</tr>
	<tr>
		<td width="112">Name</td>
		<td width="162"><input type="text" name="txtFirstName" size="40" value = <?php echo $firstName ?>></td>
	</tr>
		<tr>
		<td width="112">Surname</td>
		<td width="162"><input type="text" name="txtLastName" size="40" value = <?php echo $lastName ?>></td>
	</tr>
	<tr>
		<td width="112">Citizenship Number</td>
		<td width="162"><input type="text" name="txtTC_Kimlik" size="40" value = <?php echo $citizenship ?>></td>
	</tr>
	<tr>
		<td width="112">Date of Birth (DD/MM/YYYY)</td>
		<td width="162"><input type="text" name="txtBirthDate1" size="4" value = <?php echo $birthDate1 ?>>/<input type="text" name="txtBirthDate2" size="4" value = <?php echo $birthDate2 ?>>/<input type="text" name="txtBirthDate3" size="10" value = <?php echo $birthDate3 ?>></td>
	</tr>
	<tr>
		<td width="112">Place of Birth</td>
		<td width="162"><input type="text" name="txtBirthPlace" size="40" value = <?php echo $birthPlace ?>></td>
	</tr>
	<tr>
		<td width="112">Address</td>
		<td width="162"><textarea rows="3" name="txtAddress" cols="40"><?php echo $address ?></textarea></td>
	</tr>
	<tr>
		<td width="112">Home telephone</td>
		<td width="162"><input type="text" name="txtHomeTel" size="40" value = <?php echo $homeTel ?>></td>
	</tr>
	<tr>
		<td width="112">Office telephone</td>
		<td width="162"><input type="text" name="txtOfficeTel" size="40" value = <?php echo $officeTel ?>></td>
	</tr>
	<tr>
		<td width="112">Mobile telephone</td>
		<td width="162"><input type="text" name="txtMobileTel" size="40" value = <?php echo $mobileTel ?>></td>
	</tr>
	<!--  <tr>
		<td width="112">Picture</td>
		<td width="162"><input type="text" name="txt" size="40"><button>Browse...</button></textarea></td>
	</tr>
	-->
	<!-- <tr>
		<td width="112">Program</td>
		<td width="162"><select><option>IS</option><option>SM</option><option>MODSIM</option></select></td>
	</tr>
	-->
		<tr>
		<td width="112">Academic Details</td>
		<td width="162"><textarea rows="4" name="txtAcademic" cols="40"><?php echo $academic ?></textarea></td>
	</tr>
</table>
	<input type="submit" value="Save" name="btnSubmit">&nbsp;&nbsp;
	<input type="reset" value="Clear" name="btnClear">&nbsp;
	<input type="submit" value="Cancel" name="btnCancel">&nbsp;
</form>
</center>

<br>
<hr color="blue">
<p>
  <a href="../../StudentIndex.php">Back</a>
</p>


</body>
</html>


